package cn.ycc1.boot3redisson.controller;

import cn.ycc1.boot3redisson.annotation.MyRedissonLock;
import cn.ycc1.boot3redisson.service.ThreadRedissonAnnotationService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ycc
 * @date 2024/7/28
 * https://blog.csdn.net/u011628753/article/details/127219291
 * Redisson分布式锁
 */
@RestController
@RequestMapping("/redisson")
@RequiredArgsConstructor
public class ThreadRedissonAnnotationController {
    private final ThreadRedissonAnnotationService threadRedissonAnnotationService;
    @GetMapping("/test")
//    @Redisson
//    @Redisson(value = "mylock-", key = "#uid")
//    @MyRedissonLock(value = "my:redisson:lock", key = "#uid")
    public String test() {
        threadRedissonAnnotationService.test();
        return "test redisson annotation";
    }

    @GetMapping("/test2")
//    @MyRedissonLock(key = "my:redisson:lock3")
    @MyRedissonLock
    public String test2(Integer id) {
        return "redisson test2" + id;
    }
}
